#ifndef UI_CORE_ATTR_DEFINE_H_
#define UI_CORE_ATTR_DEFINE_H_
#pragma once

#if BUILD_XML_GUI	
#include <unordered_map>

namespace ui
{

//class Control;


typedef std::function<std::wstring()> GetAttrValueCallback;
typedef std::function<void(const std::wstring)> SetAttrValueCallback;
struct ContrlAttrVistorItem {
	std::wstring sAttrName;
	std::wstring sDefaultValue;
	GetAttrValueCallback cbGet;
	SetAttrValueCallback cbSet;

	std::wstring sType;		//uiClass, class, font, color, string(Normal), bool, int, double, rect, point, size, image
	/*union  {*/
	std::vector<std::wstring> vecV;
	/*} typeMap;*/

	bool enabled;

	void SetEnabled(bool bEnabled) { enabled = bEnabled; }

	ContrlAttrVistorItem(std::wstring AttrName) {
		sAttrName = AttrName; sDefaultValue = L""; cbGet = nullptr; cbSet = nullptr; sType = L"uiClass"; vecV.clear(); enabled = true;
	};
	ContrlAttrVistorItem(std::wstring AttrName, std::wstring DefaultValue, GetAttrValueCallback CbGet, SetAttrValueCallback CbSet) {
		sAttrName = AttrName; sDefaultValue = DefaultValue; cbGet = CbGet; cbSet = CbSet; sType = L"string"; vecV.clear(); enabled = true;
	};
	ContrlAttrVistorItem(std::wstring AttrName, std::wstring DefaultValue, GetAttrValueCallback CbGet, SetAttrValueCallback CbSet, std::wstring Type) {
		assert(!Type.empty());
		sAttrName = AttrName; sDefaultValue = DefaultValue; cbGet = CbGet; cbSet = CbSet; sType = Type; vecV.clear(); enabled = true;
	};
	ContrlAttrVistorItem(std::wstring AttrName, std::wstring DefaultValue, GetAttrValueCallback CbGet, SetAttrValueCallback CbSet, std::wstring Type, std::vector<std::wstring> vec) {
		assert(!Type.empty());
		sAttrName = AttrName; sDefaultValue = DefaultValue; cbGet = CbGet; cbSet = CbSet; sType = Type; vecV = vec; enabled = true;
	};

	~ContrlAttrVistorItem() {};
};

typedef std::vector<ContrlAttrVistorItem> AttrOfClass;

class ContrlAttrVistor{
public:
	std::vector<AttrOfClass> vecClass;
	bool SetAttrDefaultValue(std::wstring sAttrName, std::wstring sDefaultValue) {
		for (auto it = vecClass.rbegin(); it != vecClass.rend(); it++)
		{
			for (auto &itItem : *it)
			{
				if (itItem.sAttrName == sAttrName)
				{
					itItem.sDefaultValue = sDefaultValue;
					return true;
				}
			}
		}
		return false;
	}
public:
	int depth(){ return vecClass.size(); };
};
#endif


extern std::vector<std::wstring> gAttrListBool;
extern std::vector<std::wstring> gAttrListClass;
extern std::vector<std::wstring> gAttrListFont;
extern std::vector<std::wstring> gAttrListColor;

}// namespace ui

#endif // UI_CORE_ATTR_DEFINE_H_